package com.changdu.seatunnel.admin.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.changdu.seatunnel.admin.entity.DataCenter;
import com.changdu.seatunnel.admin.service.DataCenterService;

@RestController
@RequestMapping("/api/datacenter")
public class DataCenterController {
    
    @Autowired
    private DataCenterService dataCenterService;
    
    @GetMapping("/list")
    public List<DataCenter> list() {
        return dataCenterService.list();
    }
    
    @GetMapping("/{id}")
    public DataCenter getById(@PathVariable Integer id) {
        return dataCenterService.getById(id);
    }
    
    @PostMapping
    public boolean save(@RequestBody DataCenter dataCenter) {
        return dataCenterService.save(dataCenter);
    }
    
    @PutMapping
    public boolean update(@RequestBody DataCenter dataCenter) {
        return dataCenterService.updateById(dataCenter);
    }
    
    @DeleteMapping("/{id}")
    public boolean delete(@PathVariable Integer id) {
        return dataCenterService.removeById(id);
    }
    
} 